package com.xc.smart.controller;

import com.xc.smart.service.UserService;
import com.xc.smart.utlis.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;


/**
 * @author mtl
 * 2021/6/8
 */
@RestController
@RequestMapping
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 登录
     * @param username
     * @param password
     * @param request
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestParam String username,
                   @RequestParam String password,
                   HttpServletRequest request) {
        //用户登录 生产jwt 令牌
        R r = userService.login(username, password,request);
        return r;
    }

    @GetMapping("/logout")
    public R logout(){
        return R.ok();
    }


}
